<template>
<!-- 保单录入模块-双录节点 -->
    <div class="fillcontain">

        <div class="searchPage">
            <!-- 查询表单 -->
            <el-form :model="searchParams" :rules="rules" ref="ruleForm" label-width="120px" class="search_container" >
                <el-row class="pb20">
                    <el-col :span="6">
                        <el-form-item label="受理号码" prop="applnum">
                            <el-input v-model="searchParams.applnum" placeholder="受理号码"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="保单号码" prop="chdrnum">
                            <el-input v-model="searchParams.chdrnum" placeholder="保单号码"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item label="电子投保标识号" prop="serno">
                            <el-input v-model="searchParams.serno" placeholder="电子投保标识号"></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="6" class="text_right">
                        <el-button type="primary" icon="el-icon-search" @click="searchData"></el-button>
                        <el-button type="primary" plain  icon="el-icon-refresh" @click="resetSearch"></el-button>
                    </el-col>
                </el-row>
            </el-form>
            
            <!-- 已结案节点 -->
            <div class="node-done">
                <div class="node-done-title">
                    <span class="line">|</span>
                    <span class="txt">已结案节点</span>
                </div>
                <el-row class="node-select" v-if="applnum">
                    <el-col :span="8">
                        <el-select v-model="ind87" placeholder="请选择">
                            <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value">
                            </el-option>
                        </el-select>
                    </el-col>
                    <el-col :span="3" class="txt-right">
                        <el-button type="danger" @click="saveData">保存</el-button>
                    </el-col>
                    
                </el-row>
            </div>

        </div>
    </div>
</template>

<script>
    import constant from '@/utils/constant';
    import * as api from "@/api/policyRecord/nodeMod/dRecord.js";
    import {isCntainChinese,isSpecialCharacters,isNotAllNumber} from '@/api/refund/RefundCommon';
    export default {
        data(){
            return {
                rules:{},
                searchParams:{
                    applnum:'', //受理号
                    chdrnum:'', //保单号码
                    serno:'',//电子投保标识号
                },
                ind87: '',
                applnum: '',
                options:[
                    {
                       value:'',
                       label: '' 
                    },
                    {
                       value:'1',
                       label: '1-正确' 
                    },
                    {
                       value:'2',
                       label: '2-无递交单证' 
                    },
                    {
                       value:'3',
                       label: '3-版本错误' 
                    },
                    {
                       value:'4',
                       label: '4-投保人姓名错误/销售人员姓名错误' 
                    }
                ]
            }
        },
        created(){
           
        },
        mounted(){
            
        },
        methods: {
            // 重置
            resetSearch(){
                this.searchParams.applnum = '';
                this.searchParams.wnotnum = '';
                this.searchParams.chdrnum = '';
            },
            // 查询列表
            searchData(){
                let para = {
                    "applnum": this.searchParams.applnum,
                    "chdrnum": this.searchParams.chdrnum,
                    "serno": this.searchParams.serno
                }
                if(!para.applnum && !para.chdrnum && !para.serno){
                    this.$message({
                        message: '受理号码及保单号码及电子投保标识号必需输入一项',
                        type: 'error'
                    });
                    return false
                }
                if(para.applnum && isNotAllNumber(para.applnum)) {
                    this.$message.error("请正确输入受理号！");
					return;
                }
                if(para.chdrnum && isNotAllNumber(para.chdrnum)) {
                    this.$message.error("请正确输入保单号！");
					return;
                }
                // if(para.serno && isCntainChinese(para.serno)) {
                //     this.$message.error("请正确输入电子投保标识！");
				// 	return;
                // }

                this.applnum = "";
                this.$store.dispatch('loading/CHANGE_LOADING',true)
                api.queryScf1(para).then(res => {
                    this.$store.dispatch('loading/CHANGE_LOADING',false)
                    if(res.resultCode == constant.SUCCESS && res.data && res.data.length){
                        this.ind87 = res.data[0].ind87;
                        this.applnum = res.data[0].applnum;
                    }
                }).catch(err =>{
                    this.$store.dispatch('loading/CHANGE_LOADING',false);
                })
            },
            saveData() {
                let para = {
                    "applnum": this.applnum,
                    "ind87": this.ind87
                }
                if(!para.applnum){
                    this.$message({
                        message: '更新参数异常！',
                        type: 'error'
                    });
                    return false
                }
                this.$store.dispatch('loading/CHANGE_LOADING',true)
                api.updateScf1Ind87(para).then(res => {
                    this.$store.dispatch('loading/CHANGE_LOADING',false)
                    let message = "";
                    let type = "";
                    if(res.resultCode == constant.SUCCESS){
                        message = '保存成功！';
                        type = "success";
                    } else {
                        message = "保存失败！";
                        type = "error";
                    }
                    this.$message({
                        message: message,
                        type: type
                    });
                }).catch(err =>{
                    this.$store.dispatch('loading/CHANGE_LOADING',false);
                })
            }
        }
    }
</script>

<style lang="less" scoped>
    .search_container{
        padding: 15px 15px 0 15px;
    }

    .node-done{
        padding:15px;
        background: #fff;
        .node-done-title{
            height:42px;
            line-height: 42px;
            padding: 0 10px;
            background: #f8f8f8;
            .line{
                color: #e43552;
                margin-right: 5px;
            }
        }
        .node-select{
            padding: 15px;
            .txt-right{
                text-align: right;
            }
        }
    }

</style>



